﻿using DotNet.Common;

namespace System.Windows.Forms
{
    public class MultiplexButton : Button
    {
        public event BoolInvoker FlagChanged;

        bool _Flag;
        public bool Flag
        {
            get { return _Flag; }
            set
            {
                _Flag = value;
                base.Text = value ? _defaultText : _otherText;
                if (FlagChanged != null)
                    FlagChanged(value);
            }
        }

        string _defaultText;
        public string DefaultText
        {
            get { return _defaultText; }
            set
            {
                _defaultText = value;
                if (_Flag)
                {
                    base.Text = value;
                }
            }
        }

        string _otherText;
        public string OtherText
        {
            get { return _otherText; }
            set
            {
                _otherText = value;
                if (!_Flag)
                {
                    base.Text = value;
                }
            }
        }

        public MultiplexButton()
        {
            _Flag = true;
            _defaultText = base.Text;
        }

        public void ChangeFlag()
        {
            this.Flag = !_Flag;
        }
    }
}
